﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Forging2
{
    /// <summary>
    /// ControlPanel.xaml 的交互逻辑
    /// </summary>
    public partial class ControlPanel : Window
    {
        public ControlPanel()
        {
            InitializeComponent();
        }

        Common.Forging.ForgingOPC opc =new Common.Forging.ForgingOPC();
        Common.AppInitialization appinit;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            appinit = new Common.AppInitialization();
            appinit.LoadConfig();
            opc.opcUaClient.ConnectServer(Common.Const.Config.ForgingOPCServerPath);
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            opc.opcUaClient.Disconnect();
        }

        private void btnForging_Click(object sender, RoutedEventArgs e)
        {
           Console.WriteLine( opc.opcUaClient.WriteNode<bool>(opc.ForgingSignal,true));
        }

        private void btnSelect_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(opc.opcUaClient.WriteNode<bool>(opc.SelectSignal, true));
        }

        private void btnZero_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(opc.opcUaClient.WriteNode<bool>(opc.ZeroSignal, true));
        }

        private void btnFintsh_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(opc.opcUaClient.WriteNode<bool>(opc.ForgingFinshedSignal, true));
        }

        
    }
}
